package com.jiyun.controller;

import com.jiyun.model.statistics.Managecount;
import com.jiyun.result.Result;
import com.jiyun.service.ManagecounService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("managecount")
@CrossOrigin
public class ManagecountController {
    @Autowired
    ManagecounService managecounService;

    @RequestMapping("count/bar")
    public Map<String,Object> count(){
        List<Managecount> list = managecounService.list();

        List<Integer> liangList = new ArrayList<>();
        list.forEach(item -> liangList.add(item.getLiang()));

        List<String> joindate=new ArrayList<>();
        list.forEach(item -> joindate.add(item.getJoindate().toString()));
        Map<String, Object> map = new HashMap<>();
        map.put("liangList", liangList);
        map.put("joindate", joindate);
        for (String s : joindate) {
            System.out.println(s);
        }
        return map;
    }

    @RequestMapping("findAll")
    public Result findAll(){
        return Result.ok(managecounService.list());
    }



}
